
<div style="width: 1000px; text-align: center; margin: auto;">

<h1>OAuth 1.0a Twitter Demo</h1>

  <div style="margin-top: 20px;">
    <form accept-charset="UTF-8" action="/tweets/obtener_request_token" method="get">
      <button type="submit" class="btn btn-primary" >1 - Obtener request token</button>
    </form>
  </div>
  
  <div id="request_token" style="margin: 20px auto 20px auto; width: 700px;">  
    <% if session.has_key?('oauth_token') %> 
      <table class="table table-hover" style="text-align: left;">
        <tr>
          <th>Clave</th>
          <th>Valor</th>
        </tr>
        <tr>
          <td>oauth_token</td>
          <td><%= session['oauth_token'] %></td>
        </tr>
        <tr>
          <td>oauth_token_secret</td>
          <td><%= session['oauth_token_secret'] %></td>
        </tr>
        <tr>
          <td>oauth_callback_confirmed</td>
          <td><%= session['oauth_callback_confirmed'] %></td>
        </tr>
      </table>
    <% end %>
  </div>

  <form accept-charset="UTF-8" action="/tweets/redirigir_usuario" method="GET">
    <button type="submit" class="btn btn-primary" >2 - Redirigir a twitter</button>
  </form>

  <div id="request_token" style="margin: 20px auto 20px auto; width: 700px;">  
    <% if session.has_key?('oauth_token_2') %> 
      <table class="table table-hover" style="text-align: left;">
        <tr>
          <th>Clave</th>
          <th>Valor</th>
        </tr>
        <tr>
          <td>oauth_token</td>
          <td><%= session['oauth_token_2'] %></td>
        </tr>
        <tr>
          <td>oauth_verifier</td>
          <td><%= session['oauth_verifier'] %></td>
        </tr>
      </table>
    <% end %>
  </div>

  <form accept-charset="UTF-8" action="/tweets/obtener_access_token" method="GET">
    <button type="submit" class="btn btn-primary" >3 - Obtener access token</button>
  </form>

  <div id="request_token" style="margin: 20px auto 20px auto; width: 700px;">  
    <% if session.has_key?('oauth_token_3') %> 
      <table class="table table-hover" style="text-align: left;">
        <tr>
          <th>Clave</th>
          <th>Valor</th>
        </tr>
        <tr>
          <td>oauth_token</td>
          <td><%= session['oauth_token_3'] %></td>
        </tr>
        <tr>
          <td>oauth_token_secret</td>
          <td><%= session['oauth_token_secret_3'] %></td>
        </tr>
      </table>
    <% end %>
  </div>

  <form accept-charset="UTF-8" action="/tweets/tweet" method="GET">
    <%= text_field_tag :texto, params[:texto], :placeholder => 'Texto' %>
    <button type="submit" class="btn btn-primary" >4 - Twittear</button>
    <% if @result == 200 %>
      <span class="glyphicon glyphicon-ok"></span>
    <% end %>
  </form>

</div>

